<?php
//基础的model文件
class CommonModel extends Model {
	public $username = '' ;
	public $uid = '' ;
	public $_cookie_data = '' ;
	public function __construct(){
		parent::__construct();
		$this->_cookie_data = decode_data(cookie("admin_auth")); //获取cookie数据
		$this->username = $this->_cookie_data['username'];
		$this->uid = $this->_cookie_data['id'];
	}
	//查询表的所有字段
	function query_columns($tableName){
		$sql = "select column_name from information_schema.columns where table_name='{$tableName}'" ;
		$data =  M()->query($sql);
		$result = array() ;
		if($data){
			foreach($data as $k => $v ){
				$result[] = $v['column_name'];
			}
		}
		return $result ;
	}
}
